<template>
  <div class="page_search search_index">
	<div class="warp">
	  <div class="container">
		<div class="row">
		  <div class="col-12">
			<div class="card_result_search">
			  <div class="title">搜索结果</div>

				<!-- 文章搜索结果 -->
			  <list_result_search
				:list="result_article"
				title="中药常识"
				source_table="article"
			  ></list_result_search>

				<!-- 论坛搜索结果 -->
			  <list_result_search
				:list="result_forum"
				title="健康论坛"
				source_table="forum"
			  ></list_result_search>

						  <list_result_search
				v-if="$check_action('/ordinary_user/list', 'get')"
				:list="result_ordinary_user_user_name"
				title="普通用户用户姓名"
				source_table="ordinary_user"
			  ></list_result_search>
																		  <list_result_search
				v-if="$check_action('/expert_user/list', 'get')"
				:list="result_expert_user_name_of_expert"
				title="专家用户专家姓名"
				source_table="expert_user"
			  ></list_result_search>
																											  <list_result_search
				v-if="$check_action('/health_archives/list', 'get')"
				:list="result_health_archives_user_name"
				title="健康档案用户姓名"
				source_table="health_archives"
			  ></list_result_search>
																																	  <list_result_search
				v-if="$check_action('/recipe_classification/list', 'get')"
				:list="result_recipe_classification_recipe_type"
				title="菜谱分类菜谱类型"
				source_table="recipe_classification"
			  ></list_result_search>
												  <list_result_search
				v-if="$check_action('/medical_recipes/list', 'get')"
				:list="result_medical_recipes_recipe_name"
				title="医疗菜谱菜谱名称"
				source_table="medical_recipes"
			  ></list_result_search>
								  <list_result_search
				v-if="$check_action('/medical_recipes/list', 'get')"
				:list="result_medical_recipes_recipe_type"
				title="医疗菜谱菜谱类型"
				source_table="medical_recipes"
			  ></list_result_search>
																																				  <list_result_search
				v-if="$check_action('/expert_classification/list', 'get')"
				:list="result_expert_classification_type_of_expert"
				title="专家分类专家类型"
				source_table="expert_classification"
			  ></list_result_search>
												  <list_result_search
				v-if="$check_action('/expert_information/list', 'get')"
				:list="result_expert_information_name_of_expert"
				title="专家信息专家姓名"
				source_table="expert_information"
			  ></list_result_search>
								  <list_result_search
				v-if="$check_action('/expert_information/list', 'get')"
				:list="result_expert_information_type_of_expert"
				title="专家信息专家类型"
				source_table="expert_information"
			  ></list_result_search>
								  <list_result_search
				v-if="$check_action('/expert_information/list', 'get')"
				:list="result_expert_information_expert_phone"
				title="专家信息专家电话"
				source_table="expert_information"
			  ></list_result_search>
																														  <list_result_search
				v-if="$check_action('/health_consultation/list', 'get')"
				:list="result_health_consultation_name_of_expert"
				title="健康咨询专家姓名"
				source_table="health_consultation"
			  ></list_result_search>
																																							  <list_result_search
				v-if="$check_action('/consultation_reply/list', 'get')"
				:list="result_consultation_reply_name_of_expert"
				title="咨询回复专家姓名"
				source_table="consultation_reply"
			  ></list_result_search>
																																	  <list_result_search
				v-if="$check_action('/advisory_feedback/list', 'get')"
				:list="result_advisory_feedback_name_of_expert"
				title="咨询反馈专家姓名"
				source_table="advisory_feedback"
			  ></list_result_search>
																		</div>
		  </div>
		</div>
	  </div>
	</div>
  </div>
</template>

<script>
import mixin from "../../mixins/page.js";
import list_result_search from "../../components/diy/list_result_search.vue";

export default {
  mixins: [mixin],
  data() {
	return {
	  "query": {
		word: "",
	  },
	  "result_article": [],
	  "result_forum": [],
						"result_ordinary_user_user_name":[],
																		"result_expert_user_name_of_expert":[],
																											"result_health_archives_user_name":[],
																																	"result_recipe_classification_recipe_type":[],
												"result_medical_recipes_recipe_name":[],
								"result_medical_recipes_recipe_type":[],
																																				"result_expert_classification_type_of_expert":[],
												"result_expert_information_name_of_expert":[],
								"result_expert_information_type_of_expert":[],
								"result_expert_information_expert_phone":[],
																														"result_health_consultation_name_of_expert":[],
																																							"result_consultation_reply_name_of_expert":[],
																																	"result_advisory_feedback_name_of_expert":[],
																};
  },
  methods: {
	/**
	 * 获取文章
	 */
	get_article() {
	  this.$get("~/api/article/get_list?like=0", { page: 1, size: 10, title: this.query.word }, (json) => {
		if (json.result) {
		  this.result_article = json.result.list;
		}
	  });
	},
	/**
	 * 获取健康论坛
	 */
	get_forum() {
	  this.$get("~/api/forum/get_list?like=0", { page: 1, size: 10, title: this.query.word }, (json) => {
		if (json.result) {
		  this.result_forum = json.result.list;
		}
	  });
	},

				/**
	 * 获取user_name
	 */
	get_ordinary_user_user_name(){
		let url = "~/api/ordinary_user/get_list?like=0";
				this.$get(url, { page: 1, size: 10, "user_name": this.query.word }, (json) => {
		  if (json.result) {
			var result_ordinary_user_user_name = json.result.list;
			result_ordinary_user_user_name.map(o => o.title = o['user_name'])
	  			this.result_ordinary_user_user_name = result_ordinary_user_user_name
		 	}
		});
	},
																/**
	 * 获取name_of_expert
	 */
	get_expert_user_name_of_expert(){
		let url = "~/api/expert_user/get_list?like=0";
				url = url+"&examine_state=已通过";
				this.$get(url, { page: 1, size: 10, "name_of_expert": this.query.word }, (json) => {
		  if (json.result) {
			var result_expert_user_name_of_expert = json.result.list;
			result_expert_user_name_of_expert.map(o => o.title = o['name_of_expert'])
	  			this.result_expert_user_name_of_expert = result_expert_user_name_of_expert
		 	}
		});
	},
																									/**
	 * 获取user_name
	 */
	get_health_archives_user_name(){
		let url = "~/api/health_archives/get_list?like=0";
				this.$get(url, { page: 1, size: 10, "user_name": this.query.word }, (json) => {
		  if (json.result) {
			var result_health_archives_user_name = json.result.list;
			result_health_archives_user_name.map(o => o.title = o['user_name'])
	  			this.result_health_archives_user_name = result_health_archives_user_name
		 	}
		});
	},
																															/**
	 * 获取recipe_type
	 */
	get_recipe_classification_recipe_type(){
		let url = "~/api/recipe_classification/get_list?like=0";
				this.$get(url, { page: 1, size: 10, "recipe_type": this.query.word }, (json) => {
		  if (json.result) {
			var result_recipe_classification_recipe_type = json.result.list;
			result_recipe_classification_recipe_type.map(o => o.title = o['recipe_type'])
	  			this.result_recipe_classification_recipe_type = result_recipe_classification_recipe_type
		 	}
		});
	},
										/**
	 * 获取recipe_name
	 */
	get_medical_recipes_recipe_name(){
		let url = "~/api/medical_recipes/get_list?like=0";
				url = url+"&examine_state=已通过";
				this.$get(url, { page: 1, size: 10, "recipe_name": this.query.word }, (json) => {
		  if (json.result) {
			var result_medical_recipes_recipe_name = json.result.list;
			result_medical_recipes_recipe_name.map(o => o.title = o['recipe_name'])
	  			this.result_medical_recipes_recipe_name = result_medical_recipes_recipe_name
		 	}
		});
	},
						/**
	 * 获取recipe_type
	 */
	get_medical_recipes_recipe_type(){
		let url = "~/api/medical_recipes/get_list?like=0";
				url = url+"&examine_state=已通过";
				this.$get(url, { page: 1, size: 10, "recipe_type": this.query.word }, (json) => {
		  if (json.result) {
			var result_medical_recipes_recipe_type = json.result.list;
			result_medical_recipes_recipe_type.map(o => o.title = o['recipe_type'])
	  			this.result_medical_recipes_recipe_type = result_medical_recipes_recipe_type
		 	}
		});
	},
																																		/**
	 * 获取type_of_expert
	 */
	get_expert_classification_type_of_expert(){
		let url = "~/api/expert_classification/get_list?like=0";
				this.$get(url, { page: 1, size: 10, "type_of_expert": this.query.word }, (json) => {
		  if (json.result) {
			var result_expert_classification_type_of_expert = json.result.list;
			result_expert_classification_type_of_expert.map(o => o.title = o['type_of_expert'])
	  			this.result_expert_classification_type_of_expert = result_expert_classification_type_of_expert
		 	}
		});
	},
										/**
	 * 获取name_of_expert
	 */
	get_expert_information_name_of_expert(){
		let url = "~/api/expert_information/get_list?like=0";
				url = url+"&examine_state=已通过";
				this.$get(url, { page: 1, size: 10, "name_of_expert": this.query.word }, (json) => {
		  if (json.result) {
			var result_expert_information_name_of_expert = json.result.list;
			result_expert_information_name_of_expert.map(o => o.title = o['name_of_expert'])
	  			this.result_expert_information_name_of_expert = result_expert_information_name_of_expert
		 	}
		});
	},
						/**
	 * 获取type_of_expert
	 */
	get_expert_information_type_of_expert(){
		let url = "~/api/expert_information/get_list?like=0";
				url = url+"&examine_state=已通过";
				this.$get(url, { page: 1, size: 10, "type_of_expert": this.query.word }, (json) => {
		  if (json.result) {
			var result_expert_information_type_of_expert = json.result.list;
			result_expert_information_type_of_expert.map(o => o.title = o['type_of_expert'])
	  			this.result_expert_information_type_of_expert = result_expert_information_type_of_expert
		 	}
		});
	},
						/**
	 * 获取expert_phone
	 */
	get_expert_information_expert_phone(){
		let url = "~/api/expert_information/get_list?like=0";
				url = url+"&examine_state=已通过";
				this.$get(url, { page: 1, size: 10, "expert_phone": this.query.word }, (json) => {
		  if (json.result) {
			var result_expert_information_expert_phone = json.result.list;
			result_expert_information_expert_phone.map(o => o.title = o['expert_phone'])
	  			this.result_expert_information_expert_phone = result_expert_information_expert_phone
		 	}
		});
	},
																												/**
	 * 获取name_of_expert
	 */
	get_health_consultation_name_of_expert(){
		let url = "~/api/health_consultation/get_list?like=0";
				this.$get(url, { page: 1, size: 10, "name_of_expert": this.query.word }, (json) => {
		  if (json.result) {
			var result_health_consultation_name_of_expert = json.result.list;
			result_health_consultation_name_of_expert.map(o => o.title = o['name_of_expert'])
	  			this.result_health_consultation_name_of_expert = result_health_consultation_name_of_expert
		 	}
		});
	},
																																					/**
	 * 获取name_of_expert
	 */
	get_consultation_reply_name_of_expert(){
		let url = "~/api/consultation_reply/get_list?like=0";
				this.$get(url, { page: 1, size: 10, "name_of_expert": this.query.word }, (json) => {
		  if (json.result) {
			var result_consultation_reply_name_of_expert = json.result.list;
			result_consultation_reply_name_of_expert.map(o => o.title = o['name_of_expert'])
	  			this.result_consultation_reply_name_of_expert = result_consultation_reply_name_of_expert
		 	}
		});
	},
																															/**
	 * 获取name_of_expert
	 */
	get_advisory_feedback_name_of_expert(){
		let url = "~/api/advisory_feedback/get_list?like=0";
				this.$get(url, { page: 1, size: 10, "name_of_expert": this.query.word }, (json) => {
		  if (json.result) {
			var result_advisory_feedback_name_of_expert = json.result.list;
			result_advisory_feedback_name_of_expert.map(o => o.title = o['name_of_expert'])
	  			this.result_advisory_feedback_name_of_expert = result_advisory_feedback_name_of_expert
		 	}
		});
	},
															
  },
  components: { list_result_search },
	created(){
    this.query.word = this.$route.query.word || "";
  },
  mounted() {
	this.get_article();
	this.get_forum();
					this.get_ordinary_user_user_name();
																	this.get_expert_user_name_of_expert();
																										this.get_health_archives_user_name();
																																this.get_recipe_classification_recipe_type();
											this.get_medical_recipes_recipe_name();
							this.get_medical_recipes_recipe_type();
																																			this.get_expert_classification_type_of_expert();
											this.get_expert_information_name_of_expert();
							this.get_expert_information_type_of_expert();
							this.get_expert_information_expert_phone();
																													this.get_health_consultation_name_of_expert();
																																						this.get_consultation_reply_name_of_expert();
																																this.get_advisory_feedback_name_of_expert();
															  },
  watch: {
	$route() {
	  $.push(this.query, this.$route.query);
	  this.get_article();
	  this.get_forum();
				  this.get_ordinary_user_user_name();
																  this.get_expert_user_name_of_expert();
																									  this.get_health_archives_user_name();
																															  this.get_recipe_classification_recipe_type();
										  this.get_medical_recipes_recipe_name();
						  this.get_medical_recipes_recipe_type();
																																		  this.get_expert_classification_type_of_expert();
										  this.get_expert_information_name_of_expert();
						  this.get_expert_information_type_of_expert();
						  this.get_expert_information_expert_phone();
																												  this.get_health_consultation_name_of_expert();
																																					  this.get_consultation_reply_name_of_expert();
																															  this.get_advisory_feedback_name_of_expert();
																},
  },
};
</script>

<style scoped>
.card_search {
  text-align: center;
}
.card_result_search>.title {
  text-align: center;
  padding: 10px 0;
}
</style>
